package com.youhome.mobile.controller;


import com.youhome.common.exception.CustomException;
import com.youhome.common.response.Result;
import com.youhome.common.response.ResultCode;
import com.youhome.mobile.utils.JwtTokenUtil;
import com.youhome.service.model.BCounselor;
import com.youhome.service.service.CounselorService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

/**
 * Created by chen365 on 2018/09/17.
 */
@Api(tags = "帐号")
@RestController
@RequestMapping(value = "/accounts")
public class AccountController {
    @Autowired
    private CounselorService counselorService;

    @ApiOperation(value = "帐号详情", notes = "帐号详情", response = BCounselor.class, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @GetMapping(value = "")
    public Object detail(HttpServletRequest request) throws CustomException {
        String phone = new JwtTokenUtil().getUsernameFromToken(request);
        return new Result<>(ResultCode.SUCCESS, counselorService.selectByPhone(phone));
    }
}
